﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using XWG.Framework;
using JWBSTAPP;

namespace JWBST.CommonClass
{
     public class SqlConditionPermission:XWG.Framework.SqlConditionList
    {
        private string[] _datarule;
        // 缓存所有条件
        private ArrayList _condList = new ArrayList();
        /// <summary>
        /// 实现数据规则的构造函数
        /// </summary>
        /// <param name="ruleCode">要实现的数据规则编码</param>
        public SqlConditionPermission(string ruleCode, string columnName, string userid)
        {
            //检索数据规则生成注入式规则条件
            XWG.Framework.IAuthority.IAuth auth = new XWG.Framework.IAuthority.Authority();
            _datarule = auth.SelectUserDataRulePermissionByCode(Global.AreaID,ruleCode, userid);
            if (_datarule != null && _datarule.Length > 0)
            {
               // _condList.Add(SqlConditionList.SqlCondition(XWG.Framework.SqlCompareOper.IN, columnName, _datarule));
                _condList.Add(new SqlCondition(XWG.Framework.SqlCompareOper.IN, columnName, _datarule));
                AddLogic(new SqlCondition(XWG.Framework.SqlCompareOper.IN, columnName, _datarule), XWG.Framework.SqlLogicOper.AND_LOGIC);
            }
        }
    }
     
}
